<%--
  01_jspExample.jsp
  User: PING
  Date: 2022/9/7
  Time: 9:50
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"
        import="com.javaweb.entity.Teacher"
        import="com.javaweb.common.DBUtil"
         import="java.util.*"
         import="com.javaweb.common.StringTool"
%>
<html>
<meta charset="UTF-8">
<head>
    <title>jsp example</title>
    <link rel="stylesheet" href="../../css/main.css"/>
    <link rel="stylesheet" href="../../css/show.css"/>
</head>
<body>

<%
    // Get teacherList from DB for preparing teacher voting.
    List<Teacher> teacherList = DBUtil.queryAll() ;
    Teacher teacher = null ;
%>
    <%@include file="header.jsp"%>
    <div class="container">
        <hr>
        <div class="main">
            <div class="show">
                    <div class="list-head">
                        候选教师名单
                    </div>
                <% for (int i=0; i<teacherList.size(); i++) {
                    teacher = teacherList.get(i) ;
                %>
                    <div class="list-item">
                        <div class="item-img">
                            <img src="../../images/<%=teacher.getImgURL()%>" alt=""/>
                        </div>
                        <div class="item-info">
                            <span class="item-name"><%=teacher.getName()%></span>
                            <span class="item-gender"><%=teacher.getGender()%></span>
                            <p><%=teacher.getDesc()%></p>
                        </div>
                        <div class="item-vote">
                            <h3>得票数：</h3><span class="item-num"><%=teacher.getVote()%></span>
                            <button class="item-vote-btn"><%=teacher.getVote()%></button>
                        </div>
                        <div class="item-action">
                            <a class="action-vote-btn" href="voteProcess.jsp?name=<%=StringTool.URLEncodeInUTF(teacher.getName())%>">投票</a>
                        </div>
                    </div>
                <%}%>

            </div>
        </div>
    </div>

    <%@include file="footer.jsp"%>

</body>
</html>
